package com.jinmdz.fmis.api.api.controller;

import com.jinmdz.fmis.api.api.model.common.IdData;
import com.jinmdz.fmis.api.api.model.common.IdVersionData;
import com.jinmdz.fmis.api.api.model.transport.TransportAllData;
import com.jinmdz.fmis.api.api.model.transport.TransportAllLoadData;
import com.jinmdz.fmis.api.api.model.transport.TransportTaskData;
import com.jinmdz.fmis.api.api.service.TransportTaskService;
import com.jinmdz.fmis.api.base.BaseController;
import com.jinmdz.fmis.core.base.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 接运任务信息相关接口
 *
 * @author LiCongLu
 * @date 2020-01-20 10:15
 */
@Api(description = "接运任务信息相关接口")
@RestController()
@RequestMapping("/api/transport-task")
public class TransportTaskController extends BaseController {

    @Resource
    private TransportTaskService transportTaskService;

    /**
     * 根据transport_task表中id加载接运任务信息
     *
     * @param data 接运主键
     * @return
     * @author LiCongLu
     * @date 2020-01-20 10:19
     */
    @ApiOperation(value = "根据transport_task表中id加载接运任务信息", notes = "根据ID加载接运信息")
    @PostMapping("/load-transport-task-with-id")
    public BaseResult<TransportTaskData> loadTransportTaskWithId(@RequestBody IdData data) {
        return resultHandler(data, userItem -> transportTaskService.loadTransportTaskWithId(data));
    }

    /**
     * 保存接运任务信息到transport_task表中
     *
     * @param data 接运请求数据
     * @return
     * @author LiCongLu
     * @date 2020-01-20 10:19
     */
    @ApiOperation(value = "保存接运任务信息到transport_task表中", notes = "保存接运任务信息到transport_task表中")
    @PostMapping("/save-transport-task")
    public BaseResult<TransportTaskData> saveTransportTask(@RequestBody TransportTaskData data) {
        return resultHandler(data, userItem -> transportTaskService.saveTransportTask(userItem, data));
    }

    /**
     * 从transport_task表中删除指定id的接运任务信息记录
     *
     * @param data 主键和版本号
     * @return
     * @author LiCongLu
     * @date 2020-01-20 10:20
     */
    @ApiOperation(value = "从transport_task表中删除指定id的接运任务信息记录", notes = "从transport_task表中删除指定id的接运任务信息")
    @PostMapping("/delete-transport-task-with-id")
    public BaseResult deleteTransportTaskWithId(@RequestBody IdVersionData data) {
        return resultHandler(data, userItem -> transportTaskService.deleteTransportTaskWithId(userItem, data));
    }

    /**
     * 接运任务，界面权限验证及基础数据加载
     *
     * @param data 加载全部数据
     * @return
     * @author LiCongLu
     * @date 2020-01-20 10:22
     */
    @ApiOperation(value = "接运任务，界面权限验证及基础数据加载", notes = "根据ID加载接运信息")
    @PostMapping("/load-transport-task-all")
    public BaseResult<TransportAllLoadData> loadTransportTaskAll(@RequestBody TransportAllData data) {
        return resultHandler(data, userItem -> transportTaskService.loadTransportTaskAll(data));
    }
}
